<?php
/**
 * Author：晴天 QQ：1186258278
 * Creation：2020/4/5 19:56
 * Filename：class.php
 * 商品分类，一级类
 */
if (!defined('IN_CRONLITE')) die();
$DB = \Medoo\DB\SQL::DB();
if (empty((int)$_QET['cid'])) {
    $DataCid = $DB->get('class', ['cid'], ['state' => 1, 'ORDER' => ['sort' => 'DESC', 'LIMIT' => 1]]);
    if ($DataCid) $cid = $DataCid['cid'];
} else $cid = (int)$_QET['cid'];
$DataArr = $DB->select('class', ['name', 'cid', 'content'], ['state' => 1, 'ORDER' => ['sort' => 'DESC']]);
$content = '';
$name = '';
foreach ($DataArr as $value) {
    if ($value['cid'] <> $cid) continue;
    $content = $value['content'];
    $name = $value['name'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html style="<?= background::image() == false ? 'background:linear-gradient(to left, #70e1f5, #ffd194);' : background::image() ?>">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta name="renderer" content="webkit"/>
    <meta name="force-rendering" content="webkit"/>
    <title><?= $name ?> - <?= $conf['sitename'] . ($conf['title'] == '' ? '' : ' - ' . $conf['title']) ?></title>
    <meta name="keywords" content="<?= $conf['keywords'] ?>">
    <meta name="description" content="<?= $conf['description'] ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo $cdnserver; ?>assets/layui/css/layui.css"/>
    <link type="text/css" rel="stylesheet" href="<?php echo $cdnserver; ?>assets/AppStore/css2/style.css"/>
</head>
<body>
<div class="headerbox">
    <div class="header">
        <div class="headerL">
            <a onclick="javascript:history.back(-1)" class="goback"><img src="/assets/AppStore/images/goback.png"/></a>
        </div>
        <div class="headerC0">
            <div class="ssdiv">
                <input id="value" type="text" value="<?= $_QET['name'] ?>" placeholder="搜索需要的商品吧！"/>
                <a href="javascript:location.href='/?name='+document.getElementById('value').value;"><img
                            src="/assets/AppStore/images/ss.png"/></a>
            </div>
        </div>
        <div class="headerR">
            <a href="/">取消</a>
        </div>
    </div>
</div>
<div class="clear"></div>
<div class="hbox"></div>
<div class="shoptypebox" style="margin-bottom: 2.7rem;">
    <div class="shtypeLeft">
        <ul>
            <?php $a = 0;
            foreach ($DataArr as $v) { ?>
                <li class="<?= ($cid == $v['cid'] ? 'on' : '') ?>">
                    <a href="?mod=class&cid=<?= $v['cid'] ?>" class="layui-elip "><?= $v['name'] ?></a></li>
                <?php ++$a;
            } ?>
        </ul>
    </div>
    <div class="shtypeRight">
        <div class="boxOne">
            <a name="m1">
                <div class="box1" <?= ($content == '' ? 'style="display: none"' : '') ?>>
                    <?= $content ?>
                </div>
                <div class="box2 botrtop">
                    <p><?= $name ?></p>
                </div>
            </a>
            <div class="box3">
                <ul id="Goods"></ul>
            </div>
        </div>
        <div style="text-align: center;margin-top: 1em;" class="layui-text">
            <div>© <?= $conf['sitename'] ?>. All rights reserved.</div>
            <div><?= $conf['notice_bottom'] ?></div>
            <div><?= $conf['statistics'] ?></div>
        </div>
    </div>
</div>
<div class="clear"></div>

<div class="footbox">
    <div class="footer jq22-footer jq22-footer-fixed">
        <a href="/" class="jq22-tabBar-item">
                <span class="jq22-tabBar-item-icon">
                    <i class="layui-icon layui-icon-home"></i>
                </span>
            <span class="jq22-tabBar-item-text">首页</span>
        </a>
        <a href="/?mod=class" class="jq22-tabBar-item ">
                <span class="jq22-tabBar-item-icon">
                     <i class="layui-icon layui-icon-app" style="color: red"></i>
                </span>
            <span class="jq22-tabBar-item-text" style="color: red">分类</span>
        </a>
        <a href="/?mod=query" class="jq22-tabBar-item ">
                <span class="jq22-tabBar-item-icon">
                    <i class="layui-icon layui-icon-form"></i>
                </span>
            <span class="jq22-tabBar-item-text">订单</span>
        </a>
        <a href="?mod=cart" class="jq22-tabBar-item ">
                <span class="jq22-tabBar-item-icon">
                    <i class="layui-icon layui-icon-cart"></i>
                </span>
            <span class="jq22-tabBar-item-text">购物车</span>
        </a>
        <a href="user" class="jq22-tabBar-item ">
                <span class="jq22-tabBar-item-icon">
                    <i class="layui-icon layui-icon-user"></i>
                </span>
            <span class="jq22-tabBar-item-text">我的</span>
        </a>
    </div>
</div>
</div>
<script src="<?php echo $cdnpublic ?>jquery/1.12.4/jquery.min.js"></script>
<script src="<?php echo $cdnserver; ?>assets/layui/layui.all.js"></script>
<script src="<?php echo $cdnserver; ?>assets/js/main.js?var=<?= $accredit['versions'] ?>"></script>
<script>
    layer.load(2, {tiem: 999999});
    $.ajax({
        type: "post",
        url: "/ajax.php?act=getgoods&cid=<?=$cid?>",
        dataType: "json",
        success: function (data) {
            layer.closeAll();
            if (data.code == 1) {
                content = '';
                $.each(data.data, function (key, val) {
                    content += '<li>\n' +
                        '          <a href="/?mod=shop&gid=' + val['gid'] + '&cid=' + val['cid'] + '">\n' +
                        '              <img src="' + val['image'] + '" height="74" onerror="this.src=\'/assets/cloud/image/error_img.png\'">\n' +
                        '               <p class="layui-elip">' + val['name'] + '</p><div  class="layui-elip" style="text-indent: 0.2em;color: rgba(255,0,12,0.68)">￥' + val['price'] + '×' + val['quantity'] + '个</div>\n' +
                        '          </a>\n' +
                        '        </li>'
                });
                if (content == '') {
                    layer.msg('当前分类一个商品也没有！');
                    return false;
                }
                $("#Goods").html(content);
            } else layer.msg('商品列表载入失败!');
        },
        error: function () {
            layer.alert('加载失败！');
        }
    });
    layui.use('flow', function () {
        var flow = layui.flow;
        flow.lazyimg();
    });
</script>
</body>
</html>

